package main

import (
	"fmt"
)

type Person struct {
	Name   string
	Age    int
	Gender string
}

func (p Person) SayHello() {
	fmt.Println(p)
	fmt.Println("this is from Person strcut")
}

// 可以视为子结构体，模拟嵌套继承
// 属性和方法都可以继承
type Student struct {
	School string
	//Person #继承相对使用比较少，使用下方的写法
	People Person // 嵌套结构体
}

func main() {
	stu := &Student{
		School: "Peking university",
	}
	//stu.Name = "smith"
	//stu.Gender = "male"
	//stu.Age = 27
	stu.People.Name = "smith"
	stu.People.Gender = "male"
	stu.People.Age = 27

	fmt.Println(stu)

	//stu.SayHello()
	stu.People.SayHello()

}
